package cn.mdmbct.spring.starter.douyin.basis.config;

import cn.mdmbct.douyin.basis.service.DyBasisService;
import cn.mdmbct.douyin.basis.service.ProxyDyBasisService;
import cn.mdmbct.douyin.common.proxy.ServicePath;
import cn.mdmbct.douyin.common.session.DySession;
import cn.mdmbct.spring.starter.douyin.common.properties.dy.DyOpenApiProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 基本open api自动配置
 *
 * @author mdmbct  mdmbct@outlook.com
 * @date 2021/4/25 13:39
 * @modified mdmbct
 * @since 1.0
 */
@Configuration
public class DyOpenApiBasisServiceAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public DyBasisService dyBasisService(DyOpenApiProperties apiProperties, DySession dySession) {

        DyBasisService dyBasisService = new ProxyDyBasisService(dySession);
        dySession.addService((ServicePath) dyBasisService);
        return dyBasisService;
    }

}
